/*
 *  glOperations.c
 *  pr1
 *
 *  Created by Javier Quevedo on 11/5/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#include "glOperations.h"
#if defined(WIN32)
#include <GL/glut.h>
#else
#include <GLUT/glut.h>
#endif

#include <stdio.h>


void drawSquare (void)
{
	glBegin( GL_QUADS );
	glColor3f(0.8,0.2,0.2); // set vertex 0 color to be  red (R,G,B)
	glVertex3f( -15.0f, -5.0f, 0.0f ); // set vertex  0 coordinate to be (0,0.5,0)
	glVertex3f( -15.0f, 5.0f, 0.0f );
	glVertex3f( 5.0f, 5.0f, 0.0f );
	glVertex3f( 5.0f, -5.0f, 0.0f );
	glEnd(); // double buffering to avoid flicker
}

void drawWire (void)
{
	
	glBegin(GL_LINE_STRIP);
	//glBegin( GL_QUADS );
	glColor3f(0.3,0.3,1); // set vertex 0 color to be  red (R,G,B)
	glVertex3f( -3.0f, -3.0f, -1.0f ); // set vertex  0 coordinate to be (0,0.5,0)
	glVertex3f( -3.0f, 3.0f, -1.0f );
	glVertex3f( 3.0f, 3.0f, -1.0f );
	glVertex3f( 3.0f, -3.0f, -1.0f );
	glVertex3f( -3.0f, -3.0f, -1.0f );
	
	glEnd(); // double buffering to avoid flicker
}

void drawAxis (void)
{
	
	
	glColor3f(1.0, 0.0, 0.0); //red
	glBegin(GL_LINES);
	glVertex3f(-10.0, 0.0, 0.0);
	glVertex3f( 10.0, 0.0, 0.0);
	glEnd();
	
	glColor3f(0.0, 1.0, 0.0); //green
	glBegin(GL_LINES);
	glVertex3f(0.0, 10.0, 0.0);
	glVertex3f(0.0, -10.0, 0.0);
	glEnd();
	
	glColor3f(0.0, 0.0, 1.0); //blue
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 10.0);
	glVertex3f(0.0, 0.0, -10.0);
	glEnd();
	
}

void drawGround (void)
{
	
	glColor3f(1.0, 1.0, 1.0); 
	glBegin(GL_POLYGON);
		glVertex3f(-10.0, 0.0, -10.0);
		glVertex3f( 10.0, 0.0, -10.0);
		glVertex3f( 10.0, 0.0, 100.0);
		glVertex3f( -10.0, 0.0, 100.0);
	glEnd();

	
}

void drawCube (GLdouble size)
{

	glBegin(GL_QUADS);						
	
	glColor3f(0.0,1.0,0.0);		
	glVertex3f( size, size, size);
	glVertex3f( 0.0, size, size);
	glVertex3f( 0.0, size, 0.0);
	glVertex3f( size, size, 0.0);

	glColor3f(1.0,0.5,0.0);
	glVertex3f( size, 0.0, 0.0);
	glVertex3f( 0.0, 0.0, 0.0);
	glVertex3f( 0.0, 0.0, size);
	glVertex3f( size, 0.0, size);

	glColor3f(1.0,0.0,0.0);
	glVertex3f( size, size, 0.0);
	glVertex3f( 0.0, size, 0.0);
	glVertex3f( 0.0, 0.0, 0.0);
	glVertex3f( size, 0.0, 0.0);

	glColor3f(1.0,1.0,0.0);
	glVertex3f( size, 0.0, size);
	glVertex3f( 0.0, 0.0, size);
	glVertex3f( 0.0, size, size);
	glVertex3f( size, size, size);

	glColor3f(0.0,0.0,1.0);
	glVertex3f( 0.0, size, 0.0);
	glVertex3f( 0.0, size, size);
	glVertex3f( 0.0, 0.0, size);
	glVertex3f( 0.0, 0.0, 0.0);

	glColor3f(1.0,0.0,1.0);
	glVertex3f( size, size, size);
	glVertex3f( size, size, 0.0);
	glVertex3f( size, 0.0, 0.0);
	glVertex3f( size, 0.0, size);

glEnd();

}
/*
void drawGroundTexture(GLuint texture)
{
	
	
    glEnable( GL_TEXTURE_2D );
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    glBindTexture( GL_TEXTURE_2D, texture);	
	
	glBegin (GL_QUADS);
	glTexCoord2f (0.0, 0.0);
	glVertex3f (-10.0, 0.01, 10.0);
	glTexCoord2f (1.0, 0.0);
	glVertex3f (10.0, 0.01, 10.0);
	glTexCoord2f (1.0, 1.0);
	glVertex3f (10.0, 0.01, -10.0);
	glTexCoord2f (0.0, 1.0);
	glVertex3f (-10.0, 0.01, -10.0);
	glEnd ();
	
	glDisable ( GL_TEXTURE_2D );
	
}*/
